package com.lhy.wallet.service.imp;

import com.lhy.wallet.mapper.BillMapper;
import com.lhy.wallet.pojo.Bill;
import com.lhy.wallet.service.BillService;
import com.lhy.wallet.vo.BillVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: 卢辉宇
 * @date: 2023/3/10 20:55
 * @description:
 */
@Service
public class BillServiceImpl implements BillService {

    @Resource
    BillMapper billMapper;
    
    @Override
    public List<BillVO> details(Integer userId) {
        List<BillVO> billVOList = new ArrayList<>();
        List<Bill> billList = billMapper.selectByUserId(userId);
        for (int i = 0; i < billList.size(); i++) {
            Bill bill =  billList.get(i);
            BillVO billVO = new BillVO();
            billVO.setDetails(bill.getDetails());
            billVO.setRemainder(bill.getRemainder());
            billVO.setRemark(bill.getRemark());
            billVO.setTime(bill.getTime());

            billVOList.add(billVO);
        }
        return billVOList;
    }
}
